
                                        ===========
                                        ADVMATH.CPP
                                        ===========
                                        

Contents
********

ADVMATH.CPP contains 30 mathematical functions for Borland C++:

Bessel
        JBesCyl(n,x)            Cylindrical Bessel Function of the First Kind [A&S 9.1]
        YBesCyl(n,x)            Cylindrical Bessel Function of the Second Kind (x>0) [A&S 9.1]
        IBesCyl(n,x)            Modified Bessel Function, I [A&S 9.6] 
        KBesCyl(n,x)            Modified Bessel Function, K (x>0) [A&S 9.6]
        JBesSph(n,x)            Spherical Bessel Function of the First Kind [A&S 10.1]
        YBesSph(n,x)            Spherical Bessel Function of the Second Kind (x!=0) [A&S 10.1]
Gamma
        GammaFnc(x)             Gamma Function (x>0) [A&S 6.1]
        IncGamma(a,x)           Incomplete Gamma Function (a>=0,x>=0[>0 if a =0]) [A&S 6.5.3]
        SmlGamma(a,x)           Small Gamma Function (a>0,x>=0) [A&S 6.5.2]
        Digamma(x)              Digamma Function (x>0) [A&S 6.3]
        PolyGam(n,x)            Polygamma Function (x>0) [A&S 6.4]
Exponential
        ExpInt(n,x)             Exponential Integral (x>=0,n>1 if x=0) [A&S 5.1]
        Ei(x)                   Cauchy PV of -ExpInt(1,-x) when x>0 (x<=50) [A&S 5.1]
Orthogonal
        Chb1Poly(n,x)           Chebyshev Polynomial of the First Kind [A&S 22]
        Chb2Poly(n,x)           Chebyshev Polynomial of the Second Kind [A&S 22]
        GegPoly(a,n,x)          Gegenbauer (Ultraspherical) Polynomial [A&S 22]
        HerPoly(n,x)            Hermite Polynomial [A&S 22]
        JacPoly(a,b,n,x)        Jacobi Polynomial (a>-1) [A&S 22]
        LagPoly(a,n,x)          Generalized Laguerre Polynomial [A&S 22]
        LegPoly(n,x)            Legendre Polynomial [A&S 22]
        AscLeg(l,m,x)           Associated Legendre Function (|x|<=1) [A&S 8.1]
Probability
        Error(x)                Error Function [A&S 7.1]
        Nprob(x)                Normal (Gaussian) Probability Function [A&S 26.2]
        ChiSqrQ(Xsq,nu)         Chi-Square Probability Function Q (Xsq>0,nu>=1) [A&S 26.4]
Miscellaneous
        BernNum(n)              Bernoulli Number [A&S 23.1]
        BernPoly(n,x)           Bernoulli Polynomial [A&S 23.1]
        EulerNum(n)             Euler Number [A&S 23.1]
        EulerPoly(n,x)          Euler Polynomial [A&S 23.1]
        Zeta(n)                 Riemann Zeta Function (n>1) [A&S 23.2]
        Adet(*array,N)          Determinant of a NxN array 

        All of the functions are defined in M. Abramowitz & I. Stegun, "Handbook of Mathematical 
Functions" (New York: Dover Publications), which should be consulted for details.  General references are 
given above; more specific references are in the comments in the source code.

        The functions in ADVMATH.CPP are valid only for non-negative integer values of l,m,n,nu and 
real values of the other parameters in the ranges noted above.  An error message will appear if argument 
values are outside the acceptable range. 

        All functions, with one exception, give results agreeing with tables in Abramowitz & Stegun to 
the accuracy of the tables, i.e. up to as many as 15 places, with a very rare disagreement of 1 or 2 in the 
last place.  The exception is KBesCyl, which is accurate to a minimum of 8 places.  (Note that Table 9.4 
for YBesCyl has been corrected in the 9th printing of the "Handbook" by Dover Publications.)

        ADET can calculate a determinant up to size 90x90 and is very reliable in returning zero for the 
determinant of a singular matrix.

        All of the function coding is based on the cited formulas in Abramowitz & Stegun; it is as 
straight-forward as I could make it.  For the most part the approach is an obvious one, although I went 
down several blind alleys in POLYGAM before finding an elegantly simple solution.  ADET employs the 
very fast and accurate pivotal condensation algorithm after some pedestrian (but tricky) code to check for 
singularity. The only reference I can give for this algorithm is a slim undergraduate text used many years 
ago: "Determinants and Matrices" by A.C. Aitken.


Usage
*****

        These functions have been tested in Borland C++ 3.1 and 4.0.  They have been compiled in the 
Large memory model and gathered into ADVMATH.LIB on the assumption that the user will have a 386 
(with 387 numerical coprocessor) or later processor.

        The easiest way to use the functions is to copy ADVMATH.H and ADVMATH.LIB into the 
INCLUDE and LIB directories you use with your Borland C++ programs.  Create a PROJECT file for 
your program that has ADVMATH.LIB as one of its components, and put the line

                                        #include <advmath.h>

in your program.  You can then use any of the 30 functions in ADVMATH.CPP as if they were built-in 
functions of BORLAND C++.

        The programs FUNCTEST.CPP and FUNCTEST.PRJ, included in the parent ZIP file that 
contains ADVMATH.CPP, are examples of how to do this (in Borland C++ 3.1).  FUNCTEST.PRJ 
assumes that c:\borlandc\include and c:\borlandc\lib are the INCLUDE and LIB directories, and that 
c:\borlandc\p is the SOURCE directory.  These and other project options can be changed to fit your 
environment.  (A parallel process works in Borland C++ 4.0, where you create a FUNCTEST.IDE 
program instead of FUNCTEST.PRJ.  I believe the C++ 3.1 approach will also work in Turbo C, but I 
have not tested it.)

        Alternatively, of course, you can simply copy any of the functions into your own code, being sure 
both to declare them at the beginning of your program and to include any necessary identifiers from 
ADVMATH.H.  This way you can edit the code to eliminate the error messages that pop up if arguments 
are outside the allowable ranges, but note that out-of-range arguments may crash your program.  Note also 
that some of these functions call one or more of the others, so you may have to copy several of them into 
your program.  All in all, I think the project route is generally easier.

                                                        James Albertson
                                                        70154.670@compuserve.com
                                                        16 June 1996
